home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 July / macformat-092.iso / Dreamweaver 3 / Configuration / Inspectors / meta.js < prev    next >
Encoding:
Text File  |  1999-12-01  |  2.1 KB  |  74 lines

  1. //form field names:
  2. //metaAttribute - drop down menu - name is [0] and http is [1]
  3. //metaValue - text field
  4. //metaContent - text field
  5.  
  6. // *********** GLOBAL VARS *****************************
  7.  
  8. var helpDoc = MM.HELP_inspMeta;
  9.  
  10. // ******************** API ****************************
  11. function canInspectSelection(){
  12.   metaObj = getSelectedObj();
  13.   return (metaObj.tagName && metaObj.tagName=="META");
  14. }
  15.  
  16. function inspectSelection(){
  17.  
  18.   var metaObj = getSelectedObj();
  19.   var metaValue = findObject("metaValue");
  20.   var metaAttribute = findObject("metaAttribute");
  21.   var metaContent = findObject("metaContent");
  22.   var useNameAttr = metaObj.getAttribute("name") || metaObj.getAttribute("name")=="";
  23.   var thisContent = metaObj.getAttribute("content");
  24.   var thisAttribute;
  25.   
  26.  
  27.  //fill in PI
  28.   metaAttribute.selectedIndex = (useNameAttr)?0:1;
  29.   if (useNameAttr){
  30.     thisAttribute = metaObj.getAttribute("name");
  31.     findObject("metaImage").src="name.gif";
  32.   }
  33.   else{
  34.     thisAttribute = metaObj.getAttribute("http-equiv");    
  35.     findObject("metaImage").src="http.gif";
  36.   }    
  37.     
  38.   //fill in attribute value if present, otherwise fill text field with empty string    
  39.   findObject("metaValue").value = thisAttribute;    
  40.   //fill in meta content if present, otherwise fill text field with empty string
  41.   if (metaObj.getAttribute("content") || metaObj.getAttribute("content")=="")
  42.     metaContent.value = (thisContent)?thisContent:"";
  43.   showHideTranslated();    
  44. }
  45.  
  46.  
  47.  
  48.  
  49. // ******************** LOCAL FUNCTIONS ****************************
  50.  
  51. function setMetaTag(){
  52.   var metaObj=getSelectedObj();
  53.   var metaValue = findObject("metaValue").value;
  54.  
  55.  
  56.   if (findObject("metaAttribute").selectedIndex==0){
  57.     metaObj.removeAttribute("http-equiv");
  58.     metaObj.setAttribute("name",metaValue);
  59.   } else {
  60.     metaObj.removeAttribute("name");
  61.     metaObj.setAttribute("http-equiv",metaValue);
  62.   }
  63.    //attribute is removed and then re-applied so that content attribute
  64.    //always appears after name and http-equiv attributes
  65.    metaObj.removeAttribute("content"); 
  66.    metaObj.setAttribute("content",findObject("metaContent").value);
  67.  
  68. }
  69.  
  70.  
  71.  
  72.  
  73.  
  74.